package com.xdtech.base.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.xdtech.base.model.District;
import com.xdtech.core.model.BaseItem;
import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.web.freemark.item.GridColumn;

/**
 * 
 * @author max.zheng
 * @create 2015-06-02 14:02:25
 * @since 1.0
 * @see
 */
public class DistrictItem extends BaseItem implements Serializable{
	private static final long serialVersionUID = 1L;
	private Long id;
	@GridColumn(title="名称",width=200)
	private String name;
	@GridColumn(title="编码",width=100)
	private String code;
	@GridColumn(title="城市ID",width=100)
	private Long cityId;

	public void setId(Long id) {
		this.id = id;
		addQuerys("id", id);
	}
	public Long getId() {
		return id;
	}
	
	public void setName(String name) {
		this.name = name;
		addQuerys("name", name);
	}
	public String getName() {
		return name;
	}
	
	public String getCode()
	{
		return code;
	}
	public void setCode(String code)
	{
		this.code = code;
	}
	public void setCityId(Long cityId) {
		this.cityId = cityId;
		addQuerys("cityId", cityId);
	}
	public Long getCityId() {
		return cityId;
	}
	
	/**
	 * 根据model构建vo
	 * 
	 * @author max
	 * @return
	 */
	public static DistrictItem createItem(District district) {
		DistrictItem districtItem = new DistrictItem();
		BeanUtils.copyProperties(districtItem, district);
		//自定义属性设置填充
		return districtItem;
	}
	/**
	 * 根据model集合创建vo集合
	 * 
	 * @author max
	 * @return
	 */
	public static List<DistrictItem> createItems(List<District> districts) {
		List<DistrictItem> districtItems = new ArrayList<DistrictItem>();
		for (District district : districts) {
			districtItems.add(createItem(district));
		}
		return districtItems;
	}
}
